package com.yuelan.system.api.factory;

import com.yuelan.common.core.web.domain.AjaxResult;
import com.yuelan.system.api.RemoteOrderService;
import com.yuelan.system.api.domain.RentPayOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @description: 订单服务降级处理工厂
 * @Author: ZhaoYi
 * @date: 24-6-25 16:19
 */
@Component
public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteOrderFallbackFactory.class);

    @Override
    public RemoteOrderService create(Throwable throwable) {

        log.error("订单服务调用失败:{}", throwable.getMessage());
        return new RemoteOrderService() {

            @Override
            public String rentOrder(RentPayOrder rentPayOrder) {
                return "订单生成失败:" + throwable.getMessage();
            }

        };
    }
}
